{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021\log_table_a1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 6 Feb 2021, 15:56:26

{com}. do "C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021\Table A1 Replication Export.do"
{txt}
{com}. ***************************************************************************
. ***************************************************************************
. **Replication files for Enns, Moehlecke and Wlezien: "Detecting True 
. **Relationships in Time Series Data with Different Orders of Integration"**
. **Table A-1, appendix******************************************************
. **Last run: Feb 6th, 2021************************************************** 
. ***************************************************************************
. ***************************************************************************
. 
. ****************************************
. **Simulation Code to Replicate Table A-1
. ****************************************
. 
. **********************************
. *Table A-1 layout
. **********************************
. *generate excel file to store Table 1 output
. putexcel set tablea1.xlsx, sheet(sheet1) replace
{res}{txt}Note: file will be replaced when the first {cmd:putexcel} command is issued

{com}. *add labels to table
. *row labels
. putexcel A4 = "$\hat{c -(}\alpha{c )-}_1$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel A5 = "$\hat{c -(}\alpha^*{c )-}_1$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel A6 = "$\hat{c -(}\beta{c )-}_1$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel A7 = "$\hat{c -(}\beta{c )-}_2$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel A8 = "$\hat{c -(}\beta^*{c )-}_2$"
{res}{txt}file tablea1.xlsx saved

{com}. 
. *column labels
. putexcel B1 = "ADL"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel B2 = "$\rho = 0.2$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel B3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel C3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel D2 = "$\rho = 0.5$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel D3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel E3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel F2 = "$\rho = 0.8$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel F3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel G3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. 
. putexcel H1 = "GCM"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel H2 = "$\rho = 0.2$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel H3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel I3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel J2 = "$\rho = 0.5$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel J3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel K3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel L2 = "$\rho = 0.8$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel L3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel M3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. 
. putexcel N1 = "First Difference"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel N2 = "$\rho = 0.2$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel N3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel O3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel P2 = "$\rho = 0.5$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel P3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel Q3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel R2 = "$\rho = 0.8$"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel R3 = "coef"
{res}{txt}file tablea1.xlsx saved

{com}. putexcel S3 = "%"
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. 
. ************************
. **T=5000; x1 = I(0), rho=.2, .5, .8
. **x2 = I(1)
. **y = x1 + x2 
. *************************
. 
. *************************************************************************
. *************************************************************************
. *ADL
. *************************************************************************
. *************************************************************************
. *seed selected based on random.org, b/t 1 and 1000000000 - same seed used for Table 1 so that results are directly comparable
. set seed 457090451
{txt}
{com}. 
. **********
. **rho=.2
. **********
. *program drop combined_noq
. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg y l.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_3 = _b[L.x1]
. sum _sim_1 _b_x1 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000    .9967454     .002651   .9703291   1.000028
{txt}{space 7}_b_x1 {c |}{res}      2,000    1.001107    .0244754   .9211814   1.096204
{txt}{space 6}_sim_3 {c |}{res}      2,000    -.996904    .0243859   -1.08666  -.9149848
{txt}
{com}. 
. 
. *export results from ADL rho = 0.2 to excel file
. **$\hat{c -(}\alpha{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9967
{txt}
{com}. putexcel B4 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_5) if abs(_sim_1/_sim_5)>=1.96
{txt}
{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel C4 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0011
{txt}
{com}. putexcel B6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1) >=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel C6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_2$
. *ceof
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.9969
{txt}
{com}. putexcel B7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel C7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. 
. **********
. **rho=.5
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg y l.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_3 = _b[L.x1]
. sum _sim_1 _b_x1 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000     .996743    .0025504   .9793999   1.000033
{txt}{space 7}_b_x1 {c |}{res}      2,000    1.000083    .0248472   .9142356   1.072256
{txt}{space 6}_sim_3 {c |}{res}      2,000   -.9970336    .0247459  -1.073194  -.9157251
{txt}
{com}. 
. 
. *export results from ADL rho = 0.5 to excel file
. **$\hat{c -(}\alpha{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9967
{txt}
{com}. putexcel D4 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_5) if abs(_sim_1/_sim_5)>=1.96
{txt}
{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel E4 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0001
{txt}
{com}. putexcel D6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1) >=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel E6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_2$
. *coef
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.9970
{txt}
{com}. putexcel D7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel E7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. **********
. **rho=.8
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg y l.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_3 = _b[L.x1]
. sum _sim_1 _b_x1 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000     .996681    .0025567   .9828852   1.000206
{txt}{space 7}_b_x1 {c |}{res}      2,000    .9998117    .0243024   .9103448   1.089434
{txt}{space 6}_sim_3 {c |}{res}      2,000   -.9967495    .0242986  -1.089185  -.9154785
{txt}
{com}. 
. 
. *export results from ADL rho = 0.8 to excel file
. **$\hat{c -(}\alpha{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9967
{txt}
{com}. putexcel F4 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_5) if abs(_sim_1/_sim_5)>=1.96
{txt}
{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel G4 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9998
{txt}
{com}. putexcel F6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1) >=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel G6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_2$
. *coef
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.9967
{txt}
{com}. putexcel F7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel G7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. 
. *****************************************************************************
. *************************************************************************
. *FIRST-DIFFERENCE DV
. *************************************************************************
. *************************************************************************
. *Need to reset the seed to match the ADL analysis to allow direct comparison of simulations
. set seed 457090451
{txt}
{com}. 
. **********
. **rho=.2
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_2 = _b[L.x1]
. sum _b_x1 _sim_2

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      2,000    1.001122    .0245031   .9203421   1.095911
{txt}{space 6}_sim_2 {c |}{res}      2,000    -1.00015    .0242943  -1.087216  -.9206976
{txt}
{com}. 
. 
. *export results from First Difference rho = 0.2 to excel file
. **$\hat{c -(}\beta^{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0011
{txt}
{com}. putexcel N6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1)>=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel O6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^{c )-}_2$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}-1.0002
{txt}
{com}. putexcel N7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_2/_sim_5) if abs(_sim_2/_sim_5) >=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel O7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **********
. **rho=.5
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_2 = _b[L.x1]
. sum _b_x1 _sim_2

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      2,000    1.000088    .0248603   .9131823   1.071677
{txt}{space 6}_sim_2 {c |}{res}      2,000   -1.000291    .0247724  -1.080816    -.91686
{txt}
{com}. 
. *export results from First Difference rho = 0.5 to excel file
. **$\hat{c -(}\beta^{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0001
{txt}
{com}. putexcel P6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1)>=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel Q6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^{c )-}_2$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}-1.0003
{txt}
{com}. putexcel P7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_2/_sim_5) if abs(_sim_2/_sim_5) >=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel Q7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. **********
. **rho=.8
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_2 = _b[L.x1]
. sum _b_x1 _sim_2

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 7}_b_x1 {c |}{res}      2,000    .9998191    .0242926   .9110594   1.092953
{txt}{space 6}_sim_2 {c |}{res}      2,000   -1.000054    .0241396  -1.092173  -.9177153
{txt}
{com}. 
. *export results from First Difference rho = 0.8 to excel file
. **$\hat{c -(}\beta^{c )-}_1$
. *coef
. quietly sum _b_x1
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9998
{txt}
{com}. putexcel R6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_x1 = abs(_b_x1/_se_x1) if abs(_b_x1/_se_x1)>=1.96
{txt}
{com}. quietly sum tstat_x1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}100
{txt}
{com}. putexcel S6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^{c )-}_2$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}-1.0001
{txt}
{com}. putexcel R7 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_2/_sim_5) if abs(_sim_2/_sim_5) >=1.96
{txt}
{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel S7 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. *************************************************************************
. *************************************************************************
. *GECM
. *************************************************************************
. *************************************************************************
. 
. *Need to reset the seed to match the ADL analysis to allow direct comparison of simulations
. set seed 457090451
{txt}
{com}. 
. **********
. **rho=.2
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.2*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y l.y d.x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_2 = _b[D.x1]
. *_sim_3 = _b[L.x1]
. sum  _sim_1 _sim_2 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000   -.0032546     .002651  -.0296709   .0000283
{txt}{space 6}_sim_2 {c |}{res}      2,000    1.001107    .0244754   .9211814   1.096204
{txt}{space 6}_sim_3 {c |}{res}      2,000    .0042027    .0245998   -.079209   .0978944
{txt}
{com}. 
. 
. *export results from GECM rho = 0.2 to excel file
. **$\hat{c -(}\alpha^*{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.0033
{txt}
{com}. putexcel H5 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_6) if abs(_sim_1/_sim_6)>=1.96
{txt}(2,000 missing values generated)

{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}0
{txt}
{com}. putexcel I5 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0011
{txt}
{com}. putexcel H6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_dx1 = abs(_sim_2/_sim_6) if abs(_sim_2/_sim_6) >=1.96
{txt}
{com}. quietly sum tstat_dx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel I6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^*{c )-}_2$
. *coef
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}0.0042
{txt}
{com}. putexcel H8 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}(1,969 missing values generated)

{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}1.55
{txt}
{com}. putexcel I8 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. **********
. **rho=.5
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.5*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y l.y d.x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_2 = _b[D.x1]
. *_sim_3 = _b[L.x1]
. sum  _sim_1 _sim_2 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000    -.003257    .0025504  -.0206001   .0000332
{txt}{space 6}_sim_2 {c |}{res}      2,000    1.000083    .0248472   .9142356   1.072256
{txt}{space 6}_sim_3 {c |}{res}      2,000    .0030492    .0172595  -.0543089   .0595828
{txt}
{com}. 
. *export results from GECM rho = 0.5 to excel file
. **$\hat{c -(}\alpha^*{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.0033
{txt}
{com}. putexcel J5 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_6) if abs(_sim_1/_sim_6)>=1.96
{txt}(2,000 missing values generated)

{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}0
{txt}
{com}. putexcel K5 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}1.0001
{txt}
{com}. putexcel J6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_dx1 = abs(_sim_2/_sim_6) if abs(_sim_2/_sim_6) >=1.96
{txt}
{com}. quietly sum tstat_dx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel K6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^*{c )-}_2$
. *coef
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}0.0030
{txt}
{com}. putexcel J8 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}(1,990 missing values generated)

{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}.5
{txt}
{com}. putexcel K8 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
. 
. **********
. **rho=.8
. **********
. program drop combined_noq
{txt}
{com}. program define combined_noq, rclass
{txt}  1{com}. drop _all
{txt}  2{com}. set obs 5000
{txt}  3{com}. gen t = _n
{txt}  4{com}. tsset t
{txt}  5{com}. *gen stationary time series (x1)
. gen e1=invnorm(uniform())
{txt}  6{com}. gen x1=e1 if t==1
{txt}  7{com}. replace x1=.8*x1[_n-1] + e1 if t>1
{txt}  8{com}. *gen integrated time series (x2)
. gen u=invnorm(uniform())
{txt}  9{com}. gen x2=u if t==1
{txt} 10{com}. replace x2=x2[_n-1] + u if t>1
{txt} 11{com}. *gen combined times series (z) that his a function of x1 and x2
. gen q=invnorm(uniform())
{txt} 12{com}. gen y = x1 + x2 + q
{txt} 13{com}. reg d.y l.y d.x1 l.x1
{txt} 14{com}.         estat bgodfrey
{txt} 15{com}.         mat P = r(p)
{txt} 16{com}.         return scalar pvalue_bg = P[1,1] 
{txt} 17{com}. end
{txt}
{com}. 
. *Simulate the program "combined" N times and save the betas and standard errors.
. *Test whether an equation with mixed orders of integration (combined z, I(0) x1, I(1) x2)
. *can correctly identify TRUE relationships
. simulate pvalue_bg=r(pvalue_bg) _b _se, reps(2000) nodots: combined_noq
{p2colset 9 19 23 2}{...}

{txt}{p2col :command:}combined_noq{p_end}
{p2colset 1 19 23 2}{...}
{p2col :{txt}[{res:_eq2}]pvalue_bg:}{res:r(pvalue_bg)}{p_end}


{com}. 
. 
. 
. sum _eq2_pvalue_bg if _eq2_pvalue_bg<0.05

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
_eq2_pvalu~g {c |}{res}      2,000           0           0          0          0
{txt}
{com}. *_sim_1 = _b[L.y]
. *_sim_2 = _b[D.x1]
. *_sim_3 = _b[L.x1]
. sum  _sim_1 _sim_2 _sim_3

{txt}    Variable {c |}        Obs        Mean    Std. Dev.       Min        Max
{hline 13}{c +}{hline 57}
{space 6}_sim_1 {c |}{res}      2,000    -.003319    .0025567  -.0171148   .0002057
{txt}{space 6}_sim_2 {c |}{res}      2,000    .9998117    .0243024   .9103448   1.089434
{txt}{space 6}_sim_3 {c |}{res}      2,000    .0030622    .0101647  -.0283262   .0519405
{txt}
{com}. 
. 
. *export results from GECM rho = 0.8 to excel file
. **$\hat{c -(}\alpha^*{c )-}_1$
. *coef
. quietly sum _sim_1
{txt}
{com}. di %6.4f `r(mean)'
{res}-0.0033
{txt}
{com}. putexcel L5 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_ly = abs(_sim_1/_sim_6) if abs(_sim_1/_sim_6)>=1.96
{txt}(2,000 missing values generated)

{com}. quietly sum tstat_ly
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc' 
{res}0
{txt}
{com}. putexcel M5 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta{c )-}_1$
. *coef
. quietly sum _sim_2
{txt}
{com}. di %6.4f `r(mean)'
{res}0.9998
{txt}
{com}. putexcel L6 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_dx1 = abs(_sim_2/_sim_6) if abs(_sim_2/_sim_6) >=1.96
{txt}
{com}. quietly sum tstat_dx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}100
{txt}
{com}. putexcel M6 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. **$\hat{c -(}\beta^*{c )-}_2$
. *coef
. quietly sum _sim_3
{txt}
{com}. di %6.4f `r(mean)'
{res}0.0031
{txt}
{com}. putexcel L8 = `r(mean)', nformat("#0.####")
{res}{txt}file tablea1.xlsx saved

{com}. *%
. gen tstat_lx1 = abs(_sim_3/_sim_7) if abs(_sim_3/_sim_7)>=1.96
{txt}(1,990 missing values generated)

{com}. quietly sum tstat_lx1
{txt}
{com}. local perc = 100*`r(N)'/2000
{txt}
{com}. di `perc'
{res}.5
{txt}
{com}. putexcel M8 = `perc'
{res}{txt}file tablea1.xlsx saved

{com}. 
. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\Carolina\OneDrive\Documentos\@ - UT Austin\Co-Authoring\Equation Balance - CW and PE\Replication Files - Final - Feb 2021\log_table_a1.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 6 Feb 2021, 16:06:42
{txt}{.-}
{smcl}
{txt}{sf}{ul off}